<include file="Public/min-header" />
<style>
	.layui-layer-content{
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>
<div class="wrapper">
	<include file="Public/breadcrumb"/>
	<section class="content">
		<div class="row">
			<div class="col-xs-12">
				<div class="box">
					<div class="box-header">
						<nav class="navbar navbar-default">
							<div class="collapse navbar-collapse">
								<form class="navbar-form form-inline" action="{:U('Live/live_list')}" method="get">
									<div class="form-group">
										<input type="text" name="keywords" class="form-control" value="{:I('keywords')}" placeholder="请输入直播名称">
									</div>
									<!--				            <div class="form-group">-->
									<!--				            	 <select name="pid" class="form-control"> -->
									<!--                                            <option value="0">==查看所有==</option>-->
									<!--                                      <volist name="ad_position_list" id="item" key="k">-->
									<!--										<if condition="I('pid')==$item['position_id']">-->
									<!--                                            <option value="{$item.position_id}" selected="selected">{$item.position_name}</option>-->
									<!--											<else/>-->
									<!--											<option value="{$item.position_id}">{$item.position_name}</option>-->
									<!--										</if>-->
									<!--                                      </volist>-->
									<!--                                 </select>   -->
									<!--				            </div>-->
									<button type="submit" class="btn btn-primary">查询</button>
									<div class="form-group pull-right">
										<a href="{:U('Live/live')}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i> 新增直播</a>
									</div>
								</form>
							</div>
						</nav>
					</div>
					<div class="box-body">
						<div class="row">
							<div class="col-sm-12">
								<table id="list-table" class="table table-bordered table-striped dataTable">
									<thead>
									<tr role="row">
										<th>id</th>
										<th>直播名称</th>
										<th>主播名称</th>
										<th>入口图片</th>
										<th>推广图片</th>
										<th>分享二维码</th>
										<th>直播间信息</th>
										<th>直播状态</th>
										<th>预约状态</th>
										<th>预约人数</th>
										<th>是否显示</th>
										<th>排序</th>
										<th>操作</th>
									</tr>
									</thead>
									<tbody>
									<foreach name="list" item="vo" key="k" >
										<tr role="row">
											<td>{$vo[id]}</td>
											<td>{$vo[name]}</td>
											<td>{$vo.anchor_name}</td>
											<td><img alt="" src="{$vo.go_img}" width="80px" height="50px"></td>
											<td><img alt="" src="{$vo.share_img}" width="80px" height="50px"></td>
											<td><img alt="" src="{$vo.share_qr}" width="80px" height="50px"></td>
											<td>
												<if condition="$vo.pusher_url neq '' ">
													<a class="btn btn-primary" data-pusher="{$vo.pusher_url}" onclick="copyPusherFunc(this)">一键复制</a>
													<a class="btn btn-primary" data-pusher="{$vo.pusher_url}" onclick="viewPusherFunc(this)">推流二维码</a>
<!--													<a class="btn btn-primary" data-danmu="{$vo.danmu}" onclick="viewDanmuFunc(this)">公屏信息接入二维码</a>-->
													<a class="btn btn-primary" onclick="pushfunc(this)" data-id="{$vo.id}">重新生成推流二维码</a>
													<else/>
													<a class="btn btn-primary" onclick="pushfunc(this)" data-id="{$vo.id}">生成推流二维码</a>
												</if>

											</td>
											<td class="text-left">
												<select onchange="updateSort('live','id',{$vo.id},'live_status',this)" class="input-sm">
													<option value="0" <if condition="$vo.live_status eq 0"> selected="selected"</if> >未开始</option>
													<option value="1" <if condition="$vo.live_status eq 1"> selected="selected"</if> >进行中</option>
													<option value="2" <if condition="$vo.live_status eq 2"> selected="selected"</if> >已结束</option>
												</select>
											</td>
											<td>
												<img width="20" height="20" src="__PUBLIC__/images/<if condition='$vo[reservation_status] eq 1'>yes.png<else />cancel.png</if>" onclick="changeTableVal('live','id','{$vo.id}','reservation_status',this)"/>
											</td>
											<td>
												{$vo.reservation_num}
											</td>
											<td>
												<img width="20" height="20" src="__PUBLIC__/images/<if condition='$vo[dataflag] eq 1'>yes.png<else />cancel.png</if>" onclick="changeTableVal('live','id','{$vo.id}','dataflag',this)"/>
											</td>

											<td>
												<input type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onchange="updateSort('live','id','{$vo.id}','sort',this)" size="4" value="{$vo.sort}" class="input-sm" />
											</td>
											<td>
												<a class="btn btn-primary" href="{:U('live/goods',array('id'=>$vo['id']))}">产品管理</a>
												<a class="btn btn-primary" href="{:U('live/live',array('act'=>'edit','id'=>$vo['id']))}"><i class="fa fa-pencil"></i></a>
												<a class="btn btn-danger" onclick="delfunc(this)" data-url="{:U('live/liveHandle')}" data-id="{$vo.id}"><i class="fa fa-trash-o"></i></a>
											</td>
										</tr>
									</foreach>
									</tbody>
									<tfoot>

									</tfoot>
								</table>
							</div>
						</div>
						<div class="row">
							<div class="col-sm-6 text-left">
								<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
							</div>
							<div class="col-sm-6 text-right">{$page}</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div style="width:150px; display: none" id="wx_bing" ></div>
	</section>
	<script type="text/javascript" src="__PUBLIC__/js/jquery.qrcode.min.js"></script>
	<script>
		function viewPusherFunc(obj){
			$('#wx_bing').html('');
			let pusher_url = $(obj).attr('data-pusher')
			$("#wx_bing").qrcode({
				render:'table',
				width:"150",
				height: "150",
				text:pusher_url
			});
			layer.open({
				type: 1,
				shadeClose: true, //点击遮罩关闭
				title:'二维码',
				area: ['200px', '230px'], //宽高
				content: $('#wx_bing')
			});
		}

		function copyPusherFunc(obj){
			let pusher_url = $(obj).attr('data-pusher')
			// 复制到剪贴板
			var input = document.createElement('input');
			input.setAttribute('value', pusher_url);
			document.body.appendChild(input);
			input.select();
			if (document.execCommand('copy')) {
				document.execCommand('copy');
				layer.msg('复制成功');
			}
			document.body.removeChild(input);
		}

		function viewDanmuFunc(obj){
			$('#wx_bing').html('');
			let danmu = $(obj).attr('data-danmu')
			$("#wx_bing").qrcode({
				render:'table',
				width:"150",
				height: "150",
				text:danmu
			});
			layer.open({
				type: 1,
				shadeClose: true, //点击遮罩关闭
				title:'二维码',
				area: ['200px', '230px'], //宽高
				content: $('#wx_bing')
			});
		}
		function pushfunc(obj){
			layer.confirm('确认生成推流地址？', {
						btn: ['确定','取消'] //按钮
					}, function(){
						// 确定
						$.ajax({
							type : 'post',
							url : '/index.php?m=Admin&c=Live&a=pushurl',
							data : {id:$(obj).attr('data-id')},
							dataType : 'json',
							success : function(data){
								if(data){
									layer.msg('操作成功', {icon: 1});
									location.reload();
								}else{
									layer.msg(data, {icon: 2,time: 2000});
								}
//   						layer.closeAll();
							}
						})
					}, function(index){
						layer.close(index);
						return false;// 取消
					}
			);
		}
	</script>
</div>
</body>
</html>   
